package cn.dugcrs.basic.utils;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * 邮箱发送验证码
 */
public class EmailUtil {
    private static JavaMailSender javaMailSender = (JavaMailSender) ApplicationContextUtils.getBean(JavaMailSender.class);
    public static void sendMail(String from,String subject,String text , String to){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom(from);
        //邮件主题
        mailMessage.setSubject(subject);
        //收件人
        mailMessage.setTo(to);
        //设置邮件内容
        mailMessage.setText(text);
        javaMailSender.send(mailMessage);
    }
}
